package com.itheima.doudizhu1;

import java.util.ArrayList;
import java.util.Collections;

public class PokerGame {

    static ArrayList<String> list = new ArrayList<>();
    //静态代码块
    //特点：随着类的加载而加载，就执行一次
    //准备牌
    static{
        String [] colors = {"♥","♠","♣","♦"};
        String [] numbers = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};

        for (String number : numbers){
            for (String color : colors){
                list.add(color+number);
            }
        }
        list.add("小王");
        list.add("大王");

    }



    public PokerGame(){
        //洗牌
        Collections.shuffle(list);
        System.out.println(list);
        //发牌
        ArrayList<String> lord = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++){
            String poker = list.get(i);
            if(i<=2){
                lord.add(poker);
                continue;
            }

            if(i%3==0){
                player1.add(poker);
            }else if(i%3==1){
                player2.add(poker);
            }else{
                player3.add(poker);
            }
        }

        //看牌
        lookPoker("底牌",lord);
        lookPoker("钢脑壳",player1);
        lookPoker("大帅比",player2);
        lookPoker("蛋筒",player3);


    }


    public void lookPoker(String name,ArrayList<String> list){
        System.out.print(name+"：");
        for (String s : list){
            System.out.print(s+" ");
        }
        System.out.println();
    }


}
